﻿using AiXiu.BLL;
using AiXiu.IBLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AiXiu.WebSite
{
    /// <summary>
    /// VideoLikeHandler 的摘要说明
    /// </summary>
    public class VideoLikeHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            //接收参数
            string videoId = context.Request.QueryString["videoId"];
            string userIdStr = context.Request.QueryString["userId"];
            int userId = int.Parse(userIdStr);

            //执行操作
            ILikeManager likeManager = new LikeManager();
            if (likeManager.IsLike(videoId, userId))
            {
                likeManager.RemoveLike(videoId, userId);
            }
            else
            {
                likeManager.AddLike(videoId, userId);
            }
            //输出结果

            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}